/**
 * 服务台API
 */

import axios from "./request/http";
import { getToken } from "@/utils/auth";
import { isDev } from "@/configurations.js";
// export const outerBaseUrl = `/apiP4`;
// export const outerBaseUrl = `http://localhost:5566`;
export const fwtUrl = "https://gzbbn.cn-elite.com";
export const outerBaseUrl = isDev ? `/apiP4` : `${fwtUrl}:1443/api/p4ex`;

axios.defaults.headers.common["Authorization"] = getToken();
export const outerPost = (method, params) => {
  let data = params;
  if (!params instanceof FormData) {
    data = JSON.stringify(params);
  }
  return axios({
    method: "POST",
    url: `${outerBaseUrl}${method}`,
    data
  }).then(res => {
    return Promise.resolve(res.data);
  });
};

export const outeGet = (method, params) => {
  return axios
    .get(`${outerBaseUrl}${method}`, {
      params
    })
    .then(res => {
      return Promise.resolve(res.data);
    });
};

/**
 *
 * @param {*} name 获取token
 * @returns
 */
export const validateGettoken = params => {
  return outerPost("/validate/gettoken", params);
};

/**
 *
 * @param {*} name ACD报表
 * @returns
 */
export const statisticGetacdreport = params => {
  return outeGet("/statistic/getacdreport", params);
};

/**
 *
 * @param {*} name 5.ACD统计数据
 * @returns
 */
export const statisticGetacd = () => {
  return outeGet("/statistic/getacd", {});
};

/**
 *
 * @param {*} name 话后评分报表
 * @returns
 */
export const statisticGetsatisfactionreport = params => {
  return outeGet("/statistic/getsatisfactionreport", params);
};
/**
 *
 * @param {*} name 通话明细统计
 * @returns
 */
export const statisticGetucnswreport = params => {
  return outeGet("/statistic/getucnswreport", params);
};

/**
 *
 * @param {*} name 员工登录统计
 * @returns
 */
export const statisticGetloginreport = params => {
  return outeGet("/statistic/getloginreport", params);
};
